<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common :: common_head('考试管理')"></head>
<head>
    <link rel="stylesheet" th:href="@{/css/back/test-manage.css}">
</head>
<body>
<!-- 引入公共的导航部分 -->
<header th:include="~{/common/common :: common_header_back('','考试管理')}"></header>

<article>
    <!-- 侧边栏部分 -->
    <nav th:include="~{/common/common :: common_left_nav('','')}"></nav>
    <!-- 显示内容的部分 -->
    <div class="context-wrap">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">设置科目一考试的 限时时间</div>
                    <div class="layui-card-body">
                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">时间(单位:s)</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="time_limit" required lay-verify="required" placeholder="请输入整数数字" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">请输入整数</div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="subjectOne">立即提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">设置科目四考试的 限时时间</div>
                    <div class="layui-card-body">
                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">时间(单位:s)</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="time_limit" required lay-verify="required" placeholder="请输入整数数字" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">请输入整数</div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="subjectFour">立即提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <br/>
        <br/>
        <br/>
        <hr style="background-color: #00ffd9" >
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">设置科目一考试的 试题分数</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">分数(单位:题/分)</label>
                            <div class="layui-input-inline">
                                <input type="number" name="fraction" required lay-verify="required" placeholder="请输入整数数字" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">请输入整数</div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="subjectOneFraction">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">设置科目四考试的 试题分数</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">分数(单位:题/分)</label>
                            <div class="layui-input-inline">
                                <input type="number" name="fraction4" required lay-verify="required" placeholder="请输入整数数字" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">请输入整数</div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="subjectFourFraction">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>



</article>
</body>
</html>
<script>
    layui.use(['element','form'], function(){
        let form = layui.form;
        let $ = layui.jquery;
        //监听提交 -- 科目一
        form.on('submit(subjectOne)', function(data){
            console.log(data)
            $.ajax({
                url: '/question/subjectOneTestTime',
                method: 'post',
                data: data.field,
                dataType: 'JSON',
                success: function (res){
                    if (res == 1){
                        //添加成功
                        layer.msg('设置成功', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }else {
                        //添加成功
                        layer.msg('设置失败', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }
                }
            },JSON)
            return false;
        });
        form.on('submit(subjectOneFraction)', function(data){
            console.log(data)
            $.ajax({
                url: '/question/setSubjectOneFraction',
                method: 'post',
                data: data.field,
                dataType: 'JSON',
                success: function (res){
                    if (res == 1){
                        //添加成功
                        layer.msg('设置成功', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }else {
                        //添加成功
                        layer.msg('设置失败', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }
                }
            },JSON)
            return false;
        });

        //监听提交 -- 科目四
        form.on('submit(subjectFour)', function(data){
            $.ajax({
                url: '/question/subjectFourTestTime',
                method: 'post',
                data: data.field,
                dataType: 'JSON',
                success: function (res){
                    if (res == 1){
                        //添加成功
                        layer.msg('设置成功', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }else {
                        //添加成功
                        layer.msg('设置失败', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }
                }
            },JSON)
            return false;
        });
        form.on('submit(subjectFourFraction)', function(data){
            console.log(data)
            $.ajax({
                url: '/question/setSubjectFourFraction',
                method: 'post',
                data: data.field,
                dataType: 'JSON',
                success: function (res){
                    if (res == 1){
                        //添加成功
                        layer.msg('设置成功', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }else {
                        //添加成功
                        layer.msg('设置失败', {
                            time: 10000, //10s后自动关闭
                            btn: ['知道了']
                        });
                        $(".layui-form")[0].reset();
                        layui.form.render();
                    }
                }
            },JSON)
            return false;
        });
    });
</script>